﻿using System.Configuration;

namespace SPSDeploy.Extensions.Configuration
{
    /// <summary>
    /// Mappings collection
    /// </summary>
    public class MappingsCollection : ConfigurationElementCollection
    {

        #region Properties
        /// <summary>
        /// Collection element type
        /// </summary>
        public override ConfigurationElementCollectionType CollectionType
        {
            get
            {
                return ConfigurationElementCollectionType.BasicMap;
            }
        }

        /// <summary>
        /// Element name
        /// </summary>
        protected override string ElementName
        {
            get
            {
                return "mapping";
            }
        }

        /// <summary>
        /// Collection element indexer
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        public new MappingElement this[string name]
        {
            get
            {
                return (MappingElement)BaseGet(name);
            }
        }
        #endregion

        #region Overrides
        /// <summary>
        /// Create new element
        /// </summary>
        /// <returns></returns>
        protected override ConfigurationElement CreateNewElement()
        {
            return new MappingElement();
        }

        /// <summary>
        /// Return specified element key
        /// </summary>
        /// <param name="element"></param>
        /// <returns></returns>
        protected override object GetElementKey(ConfigurationElement element)
        {
            return ((MappingElement)element).Expression;
        }
        #endregion

    }
}